package com.etoak.config.imagecode;

import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @Author by 孙有泽
 * @Date 2025/2/21 17:17
 * @Description
 */
@Configuration
public class ImageConfig {
    @Bean
    public DefaultKaptcha getDafaultKaptcha(){
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        Properties properties = new Properties();
        properties.setProperty(Constants.KAPTCHA_BORDER,"yes");
        properties.setProperty(Constants.KAPTCHA_BORDER_COLOR,"105,179,90");
        properties.setProperty(Constants.KAPTCHA_IMAGE_WIDTH,"200");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR,"blue");
        properties.setProperty(Constants.KAPTCHA_IMAGE_HEIGHT,"36");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING,"0123456789");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES,"楷体");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH,"4");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE,"34");
        //图片效果
        properties.setProperty(Constants.KAPTCHA_OBSCURIFICATOR_IMPL,"com.google.code.kaptcha.impl.WaterRipple");
        Config config = new Config(properties);
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;


    }

}
